package com.cuit.mimall.controller.frontend;

import com.cuit.mimall.common.R;
import com.cuit.mimall.service.IProductService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

/**
 * @author TeaWu
 * @folder 前台/商品
 */
@RestController("frontendProductController")
@RequestMapping("/api/v1/frontend/product")
public class ProductController {
    private final IProductService productService;

    @Autowired
    public ProductController(IProductService productService) {
        this.productService = productService;
    }

    /**
     * 按分类获取商品列表
     */
    @GetMapping("/getProductsByCategory")
    public R<?> getProductsByCategory(@RequestParam Integer categoryId,
                                      @RequestParam Integer pageNum,
                                      @RequestParam Integer pageSize) {
        return productService.getProductsByCategory(categoryId, pageNum, pageSize);
    }
}
